package com.example.redisdemo.accessLimit.exception;

import com.example.redisdemo.util.HttpResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description            处理自定义的  ServiceException
 * @ClassName MyControllerAdvice
 * @Author jiang_11445266119198
 * @Date 2022/7/18 17:50
 */
@ControllerAdvice  // 全局异常的处理
public class MyControllerAdvice {

    @ResponseBody
    @ExceptionHandler(ServiceException.class)
    public HttpResult serviceExceptionHandler(ServiceException se) {
        return HttpResult.newError(se.getMsg());
    }

}
